Skip to content

fix(rsc): exclude CSS imports with special queries from automatic injection #580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 15, 2025

Conversation

hi-ogawa
Copy link
Contributor

CSS imports with special queries (?url, ?inline, ?raw) should not be collected for server-side rendering as they return strings rather than applying styles.

This fix adds a hasSpecialCssQuery() helper function to detect and exclude these imports from the collectCss function, preventing unexpected behavior while ensuring normal CSS imports continue to work correctly.

  • Add hasSpecialCssQuery() helper to detect ?url, ?inline, ?raw queries
  • Modify collectCss() to exclude CSS imports with special queries
  • Add comprehensive e2e tests for both server and client components
  • Test all query patterns with separate CSS files to ensure proper handling

Fixes #571

🤖 Generated with Claude Code

Description

CSS imports with special queries (?url, ?inline, ?raw) should not be
collected for server-side rendering as they return strings rather than
applying styles.

This fix adds a hasSpecialCssQuery() helper function to detect and exclude
these imports from the collectCss function, preventing unexpected behavior
while ensuring normal CSS imports continue to work correctly.

- Add hasSpecialCssQuery() helper to detect ?url, ?inline, ?raw queries
- Modify collectCss() to exclude CSS imports with special queries
- Add comprehensive e2e tests for both server and client components
- Test all query patterns with separate CSS files to ensure proper handling

Fixes #571

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@hi-ogawa hi-ogawa changed the title fix(rsc): exclude CSS imports with special queries from collection fix(rsc): exclude CSS imports with special queries from automatic injection Aug 14, 2025
@hi-ogawa hi-ogawa marked this pull request as ready for review August 14, 2025 09:43
@hi-ogawa hi-ogawa requested a review from Copilot August 14, 2025 09:51
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where CSS imports with special queries (?url, ?inline, ?raw) were being incorrectly collected for server-side rendering, causing unexpected behavior since these queries return strings rather than applying styles.

  • Add hasSpecialCssQuery() helper function to detect CSS imports with special queries
  • Modify collectCss() to exclude CSS imports with special queries from automatic injection
  • Add comprehensive e2e tests covering both server and client components with all query patterns

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/plugin-rsc/src/plugin.ts Core fix: adds helper function and excludes special CSS queries from collection
packages/plugin-rsc/examples/basic/src/server.tsx Updates CSP to allow inline styles for testing
packages/plugin-rsc/examples/basic/src/routes/root.tsx Integrates new CSS queries test component
packages/plugin-rsc/examples/basic/src/routes/css-queries/* Test files for CSS query functionality on both server and client
packages/plugin-rsc/e2e/basic.test.ts E2e test verifying CSS queries are not auto-injected but work when manually applied

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@hi-ogawa hi-ogawa merged commit 71bb49c into main Aug 15, 2025
20 checks passed
@hi-ogawa hi-ogawa deleted the fix/css-queries-collection branch August 15, 2025 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test and fix css import queries ?url ?inline ?raw
1 participant